PROGRAM_FILENAME = program
PROGRAM_CATALOGUE = assembler
PROGRAM = ${PROGRAM_FILENAME}.s
PROGRAM_ELF = ${PROGRAM_FILENAME}.elf
PROGRAM_OBJ = ${PROGRAM_FILENAME}.o
PROGRAM_LST = ${PROGRAM_FILENAME}.lst


DATA_FILENAME = data
DATA = ${DATA_FILENAME}.s
DATA_ELF = ${DATA_FILENAME}.elf

DATA_OBJ = ${DATA_FILENAME}.o
DATA_LST = ${DATA_FILENAME}.lst

AVR_AS = avr-as
AVR_AS_FLAGS = 

AVR_GCC = 
AVR_GCC_FLAGS = 

CXX = gcc
DATA_GEN = data_generator.c
DATA_TARGET = data_generator.exe

DATA_BIN = dataIn.bin
PROGRAM_BIN = programIn.bin
FUNC_DIR = ../tests/AND

all: program data


program:
	avr-as -mmcu=atmega128 ${PROGRAM} -o ${PROGRAM_OBJ}
	avr-gcc -mno-interrupts -mno-tablejump -nostartfiles -mmcu=atmega128 ${PROGRAM_OBJ} -o ${PROGRAM_ELF}
	avr-objcopy --output-target binary ${PROGRAM_ELF} ${PROGRAM_BIN}
	avr-objdump -d ${PROGRAM_ELF} > ${PROGRAM_LST}
	cp  ${PROGRAM_BIN} ${FUNC_DIR}
	

data:
	touch ${DATA_BIN}
	${CXX} ${DATA_GEN} -o ${DATA_TARGET}
	./${DATA_TARGET} ${DATA_BIN}
	cp ${DATA_BIN} ${FUNC_DIR}
	#od -x ${DATA_BIN}
	#make clean

clean:
	rm -f *.o *.elf *.lst *.bin *.binary